// Copyright (c) 2025 Huawei Technologies Co., Ltd.
// openUBMC is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//         http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
//
// Description: 实现kvm客户端认证管理

#pragma once

#include <boost/variant.hpp>
#include "boost/utility/string_view_fwd.hpp"
#include "ClientAuthentication.hpp"
#include "DeleteSession.hpp"
using HttpResInfo = boost::variant<HttpSuccInfo, HttpFailInfo>;

class AuthenticationManager final{
public:
    explicit AuthenticationManager();
    virtual ~AuthenticationManager() final;
    bool HttpCreateSession(boost::string_view host, boost::string_view port, boost::string_view userName,
        const char* passWord, boost::string_view kvmMode);
    bool HttpDeleteSession(boost::string_view host, boost::string_view port, boost::string_view userName,
        const char* passWord);
    // 异常回调时会被调用
    bool HttpDeleteSession();
    // 获取创建会话的http请求的返回body详情
    HttpResInfo GetCreateSessionResultInfo();
    boost::beast::http::status GetCreateStatus();
    boost::beast::http::status GetDeleteStatus();
    // 获得会话的token，如果没有会话，则返回""
    boost::string_view GetSessionToken();

private:
    ClientAuthentication* authSessionCreator_;
    DeleteSession* sessionDeleter_;
    // 记录供调用bool HttpDeleteSession()时使用
    std::string host_;
    std::string port_;
    std::string userName_;
    char* passWord_;
};
